package com.ysy.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum RedisLuaResultEnum {


    FOLLOW_LIMIT(-2L,"已经达到最大关注"),
    NOT_EXIST(-1L,"缓存不存在"),
    NOT_FOLLOW(0L,"未关注"),
    FOLLOW_SUCCESS(1L,"关注成功"),
    ALREADY_FOLLOW(2L,"已经关注了该用户"),
    CANCEL_FOLLOW_SUCCESS(3L,"取关成功"),
    ;
    private Long code;
    private String desc;

    private static final Map<Long, RedisLuaResultEnum> cache;

    static {

        cache = Arrays.stream(RedisLuaResultEnum.values()).collect(Collectors.toMap(RedisLuaResultEnum::getCode, e -> e));
    }

    public  static RedisLuaResultEnum getRedisLuaResultEnum(Long code) {
        return cache.get(code);
    }
}
